package com.epfresh.bean;

import com.epfresh.global.CartHelper;
import com.epfresh.utils.FormatUtil;

import java.util.ArrayList;
import java.util.List;

public class ListGoods implements CartHelper.CartHelperTools{

    private String jointStoreId;
    private boolean isDeleted;
    private String salesVolume;
    private String  createdTime;
    private String creatorId;
    private String chargeUnit;
    private String number;
    private String merchantId;
    private List<String> imgList;
    private String packageSize;
    private boolean purchaseIsSale;
    private String name;
    private int status;
    private String modifierId;
    private String barCode;
    private String weight;
    private boolean isProduct;
    private String deposit;
    private String productId;
    private String saleDeadline;
    private List<String> banner;


    public String getJointStoreId() {

        return jointStoreId;
    }

    public void setJointStoreId(String jointStoreId) {
        this.jointStoreId = jointStoreId;
    }

    public boolean isDeleted() {
        return isDeleted;
    }

    public void setDeleted(boolean deleted) {
        isDeleted = deleted;
    }

    public String getSalesVolume() {
        return salesVolume;
    }

    public void setSalesVolume(String salesVolume) {
        this.salesVolume = salesVolume;
    }

    public String getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(String createdTime) {
        this.createdTime = createdTime;
    }

    public String getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(String creatorId) {
        this.creatorId = creatorId;
    }

    public String getChargeUnit() {
        return chargeUnit;
    }

    public void setChargeUnit(String chargeUnit) {
        this.chargeUnit = chargeUnit;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public List<String> getImgList() {
        return imgList;
    }

    public void setImgList(List<String> imgList) {
        this.imgList = imgList;
    }

    public String getPackageSize() {
        return packageSize;
    }

    public void setPackageSize(String packageSize) {
        this.packageSize = packageSize;
    }

    public boolean isPurchaseIsSale() {
        return purchaseIsSale;
    }

    public void setPurchaseIsSale(boolean purchaseIsSale) {
        this.purchaseIsSale = purchaseIsSale;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getModifierId() {
        return modifierId;
    }

    public void setModifierId(String modifierId) {
        this.modifierId = modifierId;
    }

    public String getBarCode() {
        return barCode;
    }

    public void setBarCode(String barCode) {
        this.barCode = barCode;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public boolean isProduct() {
        return isProduct;
    }

    public void setProduct(boolean product) {
        isProduct = product;
    }

    public String getDeposit() {
        return deposit;
    }

    public void setDeposit(String deposit) {
        this.deposit = deposit;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getSaleDeadline() {
        return saleDeadline;
    }

    public void setSaleDeadline(String saleDeadline) {
        this.saleDeadline = saleDeadline;
    }

    public List<String> getBanner() {
        return banner;
    }

    public void setBanner(List<String> banner) {
        this.banner = banner;
    }

    private ProductSpecPrice productSpecPrice;
    private ProductParseDto productParseDto;

    private Promotion promotion;

    public Promotion getPromotion() {
        return promotion;
    }

    public void setPromotion(Promotion promotion) {
        this.promotion = promotion;
    }

    public static class Promotion {
        
        private String tagImageId;
        private String itemId;
        private String tagImageUrl;
        private String quantityPerAccount;
        private String id;
        private String beginTime;
        private String endTime;
        private String type;
        private String status;
        private String price;
        private String moq;
        private String markUrl;

        public String getMarkUrl() {
            return markUrl;
        }

        public void setMarkUrl(String markUrl) {
            this.markUrl = markUrl;
        }

        public String getMoq() {
            return moq;
        }

        public void setMoq(String moq) {
            this.moq = moq;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getTagImageId() {
            return tagImageId;
        }

        public void setTagImageId(String tagImageId) {
            this.tagImageId = tagImageId;
        }

        public String getItemId() {
            return itemId;
        }

        public void setItemId(String itemId) {
            this.itemId = itemId;
        }

        public String getTagImageUrl() {
            return tagImageUrl;
        }

        public void setTagImageUrl(String tagImageUrl) {
            this.tagImageUrl = tagImageUrl;
        }

        public String getQuantityPerAccount() {
            return quantityPerAccount;
        }

        public void setQuantityPerAccount(String quantityPerAccount) {
            this.quantityPerAccount = quantityPerAccount;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getBeginTime() {
            return beginTime;
        }

        public void setBeginTime(String beginTime) {
            this.beginTime = beginTime;
        }

        public String getEndTime() {
            return endTime;
        }

        public void setEndTime(String endTime) {
            this.endTime = endTime;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }
    }

    public ProductSpecPrice getProductSpecPrice() {
        return productSpecPrice;
    }

    public void setProductSpecPrice(ProductSpecPrice productSpecPrice) {
        this.productSpecPrice = productSpecPrice;
    }

    public ProductParseDto getProductParseDto() {
        return productParseDto;
    }

    public void setProductParseDto(ProductParseDto productParseDto) {
        this.productParseDto = productParseDto;
    }

    public static class ProductSpecPrice {

        /**
         * modifiedTime : 2017-03-22 14:23:30
         * productId : 2616
         * groupId : 0
         * moq : 5
         * price : 66
         * productSpecId : 2616
         * createdTime : 2017-03-22 14:23:30
         * id : 1532
         * salesStatus : true
         */

        private String modifiedTime;
        private String productId;
        private String groupId;
        private double moq;
        private double price;
        private String productSpecId;
        private String createdTime;
        private String id;
        private boolean salesStatus;
        private boolean prePrice;//  价格前置/后置(true:前置,false:后置)

        public boolean isPrePrice() {
            return prePrice;
        }

        public void setPrePrice(boolean prePrice) {
            this.prePrice = prePrice;
        }

        public String getModifiedTime() {
            return modifiedTime;
        }

        public void setModifiedTime(String modifiedTime) {
            this.modifiedTime = modifiedTime;
        }

        public String getProductId() {
            return productId;
        }

        public void setProductId(String productId) {
            this.productId = productId;
        }

        public String getGroupId() {
            return groupId;
        }

        public void setGroupId(String groupId) {
            this.groupId = groupId;
        }

        public double getMoq() {
            return moq;
        }

        public void setMoq(double moq) {
            this.moq = moq;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public String getProductSpecId() {
            return productSpecId;
        }

        public void setProductSpecId(String productSpecId) {
            this.productSpecId = productSpecId;
        }

        public String getCreatedTime() {
            return createdTime;
        }

        public void setCreatedTime(String createdTime) {
            this.createdTime = createdTime;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public boolean isSalesStatus() {
            return salesStatus;
        }

        public void setSalesStatus(boolean salesStatus) {
            this.salesStatus = salesStatus;
        }
    }
    public static class ProductParseDto {

        /**
         * modifiedTime : 2017-03-22 15:53:18
         * categoryiiId : 49
         * description : 排酸48小时精分割牛肉，自有牧场直供
         * storeId : 70
         * title : 牛腩-西门塔尔-优等品-臻回味-宁夏-1公斤
         * type : 1
         * isShareInventory : false
         * categoryiId : 3
         * number : 01170322289552
         * merchantId : 75
         * createdTime : 2017-03-22 15:53:18
         * id : 2627
         * categoryiiiId : 351
         */

        private String modifiedTime;
        private String categoryiiId;
        private String description;
        private String storeId;
        private String title;
        private String type;
        private boolean isShareInventory;
        private String categoryiId;
        private String number;
        private String merchantId;
        private String createdTime;
        private String id;
        private String categoryiiiId;
        private String modifierId;

        public String getModifierId() {
            return modifierId;
        }

        public void setModifierId(String modifierId) {
            this.modifierId = modifierId;
        }

        public String getModifiedTime() {
            return modifiedTime;
        }

        public void setModifiedTime(String modifiedTime) {
            this.modifiedTime = modifiedTime;
        }

        public String getCategoryiiId() {
            return categoryiiId;
        }

        public void setCategoryiiId(String categoryiiId) {
            this.categoryiiId = categoryiiId;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getStoreId() {
            return storeId;
        }

        public void setStoreId(String storeId) {
            this.storeId = storeId;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public boolean isShareInventory() {
            return isShareInventory;
        }

        public void setShareInventory(boolean shareInventory) {
            isShareInventory = shareInventory;
        }

        public String getCategoryiId() {
            return categoryiId;
        }

        public void setCategoryiId(String categoryiId) {
            this.categoryiId = categoryiId;
        }

        public String getNumber() {
            return number;
        }

        public void setNumber(String number) {
            this.number = number;
        }

        public String getMerchantId() {
            return merchantId;
        }

        public void setMerchantId(String merchantId) {
            this.merchantId = merchantId;
        }

        public String getCreatedTime() {
            return createdTime;
        }

        public void setCreatedTime(String createdTime) {
            this.createdTime = createdTime;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getCategoryiiiId() {
            return categoryiiiId;
        }

        public void setCategoryiiiId(String categoryiiiId) {
            this.categoryiiiId = categoryiiiId;
        }
    }
    /*
  }, {
    "tags" : [ {
      "color" : "#ff0000",
      "name" : "热销"
    }, {
      "color" : "#ff0000",
      "name" : "绿色"
    } ],
    "id" : 31,
    "title" : "高塬苹果 来自铜川耀州区",
    "level" : "一级",
    "price" : "80.0元/箱",
    "thumbnail" : "http://7xp

    "package" : "15公斤/箱",
    "origin" : "铜川市耀州区",
    "mark" : null,
    "type" : 1,
    "storeId" : 2
    * */


    String msg;
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public ArrayList<String> getFastMessages() {
        return fastMessages;
    }

    public void setFastMessages(ArrayList<String> fastMessages) {
        this.fastMessages = fastMessages;
    }

    private ArrayList<String> fastMessages;
    private String deliveryTime;
    private String pluckingTime;
    private String id;
    private String cartId;
    private String title;
    private String level;
    private String thumbnail;
    private String price;
    private String preBuyPersonsCount;
    private String origin;
    private String pack;
    private String type;
    private String mark;
    private String shoppingCarId;
    private String storeId;
    private String storeName;
    private String marketingTime;
    private String marketName;
    private String marketShortName;
    private ArrayList<HomeCommTag> tags;
    private double leastCount;
    private double moq;
    private double unitPrice;
    private double inventoryAmount;

    private double depositRatio;
    private String notice;

    private boolean isSelect;
    private Boolean show;

    private String packageContainer;
    private String packageUnit;
    private String unit;

    private double originalPrice;//原价，
    private double priceOnly;//现价，
    private double discountRate;//折扣率

    private String promotionItemQuantityPerAccount;
    private String promotionItemEndTime;
    private String promotionItemId;
    private String promotionItemType;
    private String promotionItemStatus;
    private String promotionItemBeginTime;
    private String promotionMarkUrl;
    private boolean isOfferProduct;

    public boolean isOfferProduct() {
        return isOfferProduct;
    }

    public void setOfferProduct(boolean offerProduct) {
        this.isOfferProduct = offerProduct;
    }
/*@property (nonatomic, strong) NSString *promotionItemQuantityPerAccount;
    @property (nonatomic, strong) NSString *promotionItemEndTime;
    @property (nonatomic, strong) NSString *promotionItemId;
    @property (nonatomic, strong) NSString *promotionItemType;
    @property (nonatomic, strong) NSString *promotionItemStatus;
    @property (nonatomic, strong) NSString *promotionItemBeginTime;*/


    public Boolean isShow() {
        return show == null ? false : show;
    }

    public void setShow(Boolean show) {
        this.show = show;
    }

    public String getPromotionMarkUrl() {
        return promotionMarkUrl;
    }

    public void setPromotionMarkUrl(String promotionMarkUrl) {
        this.promotionMarkUrl = promotionMarkUrl;
    }

    public double getOriginalPrice() {
        if (productSpecPrice != null) {
            return productSpecPrice.getPrice();
        }
        return originalPrice;
    }

    public void setOriginalPrice(double originalPrice) {
        this.originalPrice = originalPrice;
    }

    public String getPromotionItemQuantityPerAccount() {
        return promotionItemQuantityPerAccount;
    }

    public void setPromotionItemQuantityPerAccount(String promotionItemQuantityPerAccount) {
        this.promotionItemQuantityPerAccount = promotionItemQuantityPerAccount;
    }

    public String getPromotionItemEndTime() {
        return promotionItemEndTime;
    }

    public void setPromotionItemEndTime(String promotionItemEndTime) {
        this.promotionItemEndTime = promotionItemEndTime;
    }

    public String getPromotionItemId() {
        if (promotion != null) {
            return promotion.getItemId();
        }
        return promotionItemId;
    }

    public void setPromotionItemId(String promotionItemId) {
        this.promotionItemId = promotionItemId;
    }

    public String getPromotionItemType() {
        if (promotion != null) {
            return promotion.getType();
        }
        return promotionItemType;
    }

    public void setPromotionItemType(String promotionItemType) {
        this.promotionItemType = promotionItemType;
    }

    public String getPromotionItemStatus() {
        if (promotion != null) {
            return promotion.getStatus();
        }
        return promotionItemStatus;
    }

    public void setPromotionItemStatus(String promotionItemStatus) {
        this.promotionItemStatus = promotionItemStatus;
    }

    public String getPromotionItemBeginTime() {
        return promotionItemBeginTime;
    }

    public void setPromotionItemBeginTime(String promotionItemBeginTime) {
        this.promotionItemBeginTime = promotionItemBeginTime;
    }

    public String getShoppingCarId() {
        return shoppingCarId;
    }

    public void setShoppingCarId(String shoppingCarId) {
        this.shoppingCarId = shoppingCarId;
    }

    public void setLeastCount(double leastCount) {
        this.leastCount = leastCount;
    }

    public Double getOriginalPric() {
        return originalPrice;
    }

    public void setOriginalPric(Double originalPric) {
        this.originalPrice = originalPric;
    }

    public double getDiscountRate() {
        return discountRate;
    }

    public void setDiscountRate(double discountRate) {
        this.discountRate = discountRate;
    }

    public String getCartId() {
        return cartId;
    }

    public void setCartId(String cartId) {
        this.cartId = cartId;
    }

    public double getInventoryAmount() {
        return inventoryAmount;
    }

    public void setInventoryAmount(double inventoryAmount) {
        this.inventoryAmount = inventoryAmount;
    }

    public double getPriceOnly() {
        if (promotion != null) {
            return Double.parseDouble(promotion.getPrice());
        }
        return productSpecPrice.getPrice();
    }

    public void setPriceOnly(double priceOnly) {
        this.priceOnly = priceOnly;
    }

    public String getPackageContainer() {
        return packageContainer;
    }

    public void setPackageContainer(String packageContainer) {
        this.packageContainer = packageContainer;
    }

    public String getMarketName() {
        return marketName;
    }

    public void setMarketName(String marketName) {
        this.marketName = marketName;
    }

    public String getPackageUnit() {
        return packageUnit;
    }

    public void setPackageUnit(String packageUnit) {
        this.packageUnit = packageUnit;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getPluckingTime() {
        return pluckingTime;
    }

    public void setPluckingTime(String pluckingTime) {
        this.pluckingTime = pluckingTime;
    }

    public String getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(String deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    int isAcceptOrders;
    String modifiedTime;
    String modifiedTimeString;
    private String lastSnapshotId;
    private double count;

    double incr;/*添加购物车的倍数字段适应多倍和1倍*/

    public double getMoq() {
        if (getPromotion() != null)
            return Double.parseDouble(getPromotion().getMoq());
        if(getProductSpecPrice()!=null)
            return getProductSpecPrice().getMoq();
        return 1.0;
    }

    public void setMoq(double moq) {
        this.moq = moq;
    }

    public double getIncr() {
        return incr;
    }

    public void setIncr(double incr) {
        this.incr = incr;
    }

    public void addCartCount(double cnt) {
        if (count < 0) {
            count = 0;
        }
        count += cnt;
    }

    public double getCount() {
        return count;
    }

    public String getGoodsCount() {
        String s = FormatUtil.subZeroAndDot(count + "");
        if ("0".equals(s)) {
            return "";
        }
        return s;
    }

    @Override
    public String getUniqueKey() {
        return getIdPlus();
    }

    public void setCount(double count) {
        this.count = count;
    }

    public String getLastSnapshotId() {
        return lastSnapshotId;
    }

    public void setLastSnapshotId(String lastSnapshotId) {
        this.lastSnapshotId = lastSnapshotId;
    }

    public String getStoreName() {
        return storeName == null ? "" : storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getModifiedTimeString() {
        return modifiedTimeString;
    }

    public void setModifiedTimeString(String modifiedTimeString) {
        this.modifiedTimeString = modifiedTimeString;
    }

    public void setIsSelect(boolean isSelect) {
        this.isSelect = isSelect;
    }

    public int getIsAcceptOrders() {
        return isAcceptOrders;
    }

    public void setIsAcceptOrders(int isAcceptOrders) {
        this.isAcceptOrders = isAcceptOrders;
    }

    public String getModifiedTime() {
        return modifiedTime;
    }

    public void setModifiedTime(String modifiedTime) {
        this.modifiedTime = modifiedTime;
    }

    public ListGoods() {
    }

    public ListGoods(String notice, double unitPrice, int leastCount, String marketingTime, String preBuyPersonsCount, String id, String title, String level, String thumbnail, String price, String origin, String pack, String type, String mark, String storeId, ArrayList<HomeCommTag> tags) {
        this.id = id;
        this.notice = notice;
        this.unitPrice = unitPrice;
        this.leastCount = leastCount;
        this.marketingTime = marketingTime;
        this.preBuyPersonsCount = preBuyPersonsCount;
        this.title = title;
        this.level = level;
        this.thumbnail = thumbnail;
        this.price = price;
        this.origin = origin;
        this.pack = pack;
        this.type = type;
        this.mark = mark;
        this.storeId = storeId;
        this.tags = tags;
    }

    public double getDepositRatio() {
        return depositRatio;
    }

    public void setDepositRatio(double depositRatio) {
        this.depositRatio = depositRatio;
    }

    public String getNotice() {
        return notice;
    }

    public void setNotice(String notice) {
        this.notice = notice;
    }

    public double getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(double unitPrice) {
        this.unitPrice = unitPrice;
    }

    public double getLeastCount() {
        return leastCount;
    }

    public void setLeastCount(int leastCount) {
        this.leastCount = leastCount;
    }

    public String getMarketingTime() {
        return marketingTime;
    }

    public void setMarketingTime(String marketingTime) {
        this.marketingTime = marketingTime;
    }

    public String getPreBuyPersonsCount() {
        return preBuyPersonsCount;
    }

    public void setPreBuyPersonsCount(String preBuyPersonsCount) {
        this.preBuyPersonsCount = preBuyPersonsCount;
    }

    public String getId() {
        return id;
    }
    public String getIdPlus() {
        if (promotion != null ){
            return id+"|"+promotion.itemId;
        }
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        if(getProductParseDto()!=null&&getProductParseDto().getTitle()!=null)
            return getProductParseDto().getTitle();
        else
            return "未命名商品";
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public String getThumbnail() {
        return thumbnail;
    }

    public void setThumbnail(String thumbnail) {
        this.thumbnail = thumbnail;
    }

    public double getPrice() {
        if(getProductSpecPrice()!=null)
            return getProductSpecPrice().getPrice();
        else
            return 0.0;
    }
    public String getPriceUnit() {
        return "元/"+ unit;
    }

    public String getPriceFloat() {
        String s = null;
        if (price != null && price.contains("元")) {
            int index = price.indexOf("元");
            s = price.substring(0, index);
        }

        return s;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getOrigin() {
        return origin;
    }

    public void setOrigin(String origin) {
        this.origin = origin;
    }

    public String getPack() {
        return pack;
    }

    public void setPack(String pack) {
        this.pack = pack;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public ArrayList<HomeCommTag> getTags() {
        return tags;
    }

    public void setTags(ArrayList<HomeCommTag> tags) {
        this.tags = tags;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public long getProductIdLong() {
        long l = 0;
        if (id != null && !"".equals(id)) {
            l = Long.valueOf(id);
        }
        return l;
    }

    public String getMarketShortName() {
        return marketShortName;
    }

    public void setMarketShortName(String marketShortName) {
        this.marketShortName = marketShortName;
    }

    public boolean isAcceptOrders() {
        return isAcceptOrders != 1 ? false : true;
    }

    public String getMarketStoreName(){
        String market = "" ;
        if (marketShortName != null && marketShortName.length() > 0){
            market = marketShortName + "  ";
        }

        if (storeName == null){
            return market;
        }
        return market + storeName;
    }
}
